<link href="/css/default/mac/menu/menu.min.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/js/mac/contextMenu.min.js"></script>
<script type="text/javascript" src="/js/mac/menu.min.js"></script>
<script type="text/javascript">
$(function(){
	var dd = [], i=0;
	for (i=0; i<10; i++) {
		var a = {
			code: 'tab' + i,
			title: 'Subject ' + i,
			closeable: i>0,
			el: 'Content of Tab' + i // You can put anything here
		};
		dd.push(a);
	}
	var tabs = $('.tabs'), mu = $('#ctxMenu');
	tabs.mac('tabs', {
		items: dd,
		onShowTab: function(me, a, b, p){
			a.contextMenu({
				menu: mu,
				button: 3, //3: right click, 1: left click
				onPopup : function(el) {
					mu.enableItems();
					if (!p.closeable)
						mu.disableItems('close');
					return true;
				},
				offset: { x: 0, y: 0 }
			}, function(action, el, pos) {
				var c = el.attr('name');
				switch (action) {
				case 'close':
					me.closeTab(c);
					break;
				case 'closeOthers':
					me.closeTabs(c);
					break;
				case 'closeAll':
					me.closeTabs();
					break;
				}
				return false;
			});
		}
	}).selectFirst();
	var atBtn = $('#addTabBtn').click(function(){
		var a = tabs.addTab({
			code: 'tab' + i,
			title: 'Subject ' + i,
			closeable: i>0,
			el: 'Content of Tab' + i // You can put anything here
		});
		tabs.select('tab' + i);
		i++;
	});
});
</script>
<div class="toolbar">
	<div class="item button" id="addTabBtn">Add Tab</div>
</div>
<div class="clear"></div>
<div class="tabs" style="height: 380px; margin: 4px;"></div>
<ul id="ctxMenu" class="contextMenu">
	<li action="close" class="ui-helper-clearfix">
		<span style="display: block">
			<span class="icon icon-newwin"></span>
			<span class="text">Close</span>
		</span>
	</li>
	<li action="closeOthers" class="ui-helper-clearfix">
		<span style="display: block">
			<span class="icon icon-newwin"></span>
			<span class="text">Close Others&nbsp;</span>
		</span>
	</li>
	<li action="closeAll" class="ui-helper-clearfix">
		<span style="display: block">
			<span class="icon icon-newwin"></span>
			<span class="text">Close All</span>
		</span>
	</li>
</ul>